<?php
/**
 * 相应的封装
 *
 * @since 1.0
 * @package if
 * @subpackage controller.context
 */
class IResponse extends IObject {
	private static $instance;
	private $headers = array();
	
	private function __construct() {
		
	}
	
	/**
	 * 取得当前类的单例
	 *
	 * @return IResponse
	 * @since 1.0
	 */
	static function singleton() {
		if (!self::$instance) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	* 跳转到其它页面,并终止程序的执行
	* 
	* 将会导致程序的终止
	* 
	* @param string $url 要转向的地址或路径
	*/
    function redirect($url) {
    	if (if_empty($url)) {
    		$url = "/";
    	}
   		$file = null;
    	$line = null;
    	if ((isset($_SERVER["SERVER_SOFTWARE"]) && preg_match("/IIS/", $_SERVER["SERVER_SOFTWARE"])) || headers_sent($file, $line)) {
    		echo "<script language=\"javascript\">window.location=\"" . str_replace("\"", "%22", $url) . "\";</script>";	
    	}
    	else {
   			header("location:" . $url);	
    	}
        exit();
    }
}


?>